load("//:build_variables.bzl", "COPTS")
load("//tools/lint:linters.bzl", "clang_tidy_test")

package(
    default_visibility = ["//:android_cuttlefish"],
)

exports_files([".clang-tidy"])

cc_library(
    name = "android_build",
    srcs = ["android_build.cc"],
    hdrs = ["android_build.h"],
    copts = COPTS,
    strip_include_prefix = "//cuttlefish",
    deps = [
        "//cuttlefish/common/libs/utils:environment",
        "//libbase",
    ],
)

clang_tidy_test(
    name = "android_build_clang_tidy",
    srcs = [":android_build"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_library(
    name = "android_build_api",
    srcs = ["android_build_api.cpp"],
    hdrs = ["android_build_api.h"],
    copts = COPTS,
    strip_include_prefix = "//cuttlefish",
    deps = [
        "//cuttlefish/common/libs/utils:contains",
        "//cuttlefish/common/libs/utils:environment",
        "//cuttlefish/common/libs/utils:files",
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/host/libs/web/cas:cas_downloader",
        "//cuttlefish/host/libs/web/http_client",
        "//cuttlefish/host/libs/web/http_client:http_file",
        "//cuttlefish/host/libs/web/http_client:http_json",
        "//cuttlefish/host/libs/web/http_client:url_escape",
        "//cuttlefish/host/libs/web:android_build",
        "//cuttlefish/host/libs/web:android_build_string",
        "//cuttlefish/host/libs/web:build_api",
        "//cuttlefish/host/libs/web:credential_source",
        "//libbase",
        "@jsoncpp",
    ],
)

clang_tidy_test(
    name = "android_build_api_clang_tidy",
    srcs = [":android_build_api"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_library(
    name = "android_build_string",
    srcs = ["android_build_string.cpp"],
    hdrs = ["android_build_string.h"],
    copts = COPTS,
    strip_include_prefix = "//cuttlefish",
    deps = [
        "//cuttlefish/common/libs/utils:flag_parser",
        "//cuttlefish/common/libs/utils:result",
        "//libbase",
        "@fmt",
    ],
)

clang_tidy_test(
    name = "android_build_string_clang_tidy",
    srcs = [":android_build_string"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_test(
    name = "android_build_string_test",
    srcs = ["android_build_string_tests.cpp"],
    copts = COPTS,
    deps = [
        "//cuttlefish/common/libs/utils:flag_parser",
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/common/libs/utils:result_matchers",
        "//cuttlefish/host/libs/web:android_build_string",
        "@googletest//:gtest",
        "@googletest//:gtest_main",
    ],
)

clang_tidy_test(
    name = "android_build_string_test_clang_tidy",
    srcs = [":android_build_string_test"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_library(
    name = "build_api",
    hdrs = ["build_api.h"],
    copts = COPTS,
    strip_include_prefix = "//cuttlefish",
    deps = [
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/host/libs/web:android_build",
        "//cuttlefish/host/libs/web:android_build_string",
    ],
)

clang_tidy_test(
    name = "build_api_clang_tidy",
    srcs = [":build_api"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_library(
    name = "build_zip_name",
    srcs = ["build_zip_name.cc"],
    hdrs = ["build_zip_name.h"],
    copts = COPTS,
    strip_include_prefix = "//cuttlefish",
    deps = [
        "//cuttlefish/host/libs/web:android_build",
    ],
)

cc_library(
    name = "caching_build_api",
    srcs = ["caching_build_api.cpp"],
    hdrs = ["caching_build_api.h"],
    copts = COPTS,
    strip_include_prefix = "//cuttlefish",
    deps = [
        "//cuttlefish/common/libs/utils:files",
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/host/libs/web/cas:cas_downloader",
        "//cuttlefish/host/libs/web/http_client",
        "//cuttlefish/host/libs/web:android_build",
        "//cuttlefish/host/libs/web:android_build_api",
        "//cuttlefish/host/libs/web:android_build_string",
        "//cuttlefish/host/libs/web:build_api",
        "//cuttlefish/host/libs/web:credential_source",
        "//libbase",
        "@fmt",
    ],
)

clang_tidy_test(
    name = "caching_build_api_clang_tidy",
    srcs = [":caching_build_api"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_library(
    name = "chrome_os_build_string",
    srcs = ["chrome_os_build_string.cpp"],
    hdrs = ["chrome_os_build_string.h"],
    copts = COPTS,
    strip_include_prefix = "//cuttlefish",
    deps = [
        "//cuttlefish/common/libs/utils:flag_parser",
        "//cuttlefish/common/libs/utils:result",
        "//libbase",
        "@fmt",
    ],
)

clang_tidy_test(
    name = "chrome_os_build_string_clang_tidy",
    srcs = [":chrome_os_build_string"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_library(
    name = "credential_source",
    srcs = ["credential_source.cc"],
    hdrs = ["credential_source.h"],
    copts = COPTS,
    strip_include_prefix = "//cuttlefish",
    deps = [
        "//cuttlefish/common/libs/utils:base64",
        "//cuttlefish/common/libs/utils:files",
        "//cuttlefish/common/libs/utils:json",
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/host/libs/web/http_client",
        "//cuttlefish/host/libs/web/http_client:http_json",
        "//cuttlefish/host/libs/web/http_client:url_escape",
        "//libbase",
        "@boringssl//:crypto",
        "@jsoncpp",
    ],
)

clang_tidy_test(
    name = "credential_source_clang_tidy",
    srcs = [":credential_source"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_library(
    name = "luci_build_api",
    srcs = ["luci_build_api.cpp"],
    hdrs = ["luci_build_api.h"],
    copts = COPTS,
    strip_include_prefix = "//cuttlefish",
    deps = [
        "//cuttlefish/common/libs/utils:json",
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/host/libs/web:chrome_os_build_string",
        "//cuttlefish/host/libs/web:credential_source",
        "//cuttlefish/host/libs/web/http_client",
        "//cuttlefish/host/libs/web/http_client:http_file",
        "//cuttlefish/host/libs/web/http_client:http_string",
        "//cuttlefish/host/libs/web/http_client:url_escape",
        "//libbase",
        "@fmt",
        "@jsoncpp",
    ],
)

clang_tidy_test(
    name = "luci_build_api_clang_tidy",
    srcs = [":luci_build_api"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_library(
    name = "oauth2_consent",
    srcs = ["oauth2_consent.cpp"],
    hdrs = ["oauth2_consent.h"],
    copts = COPTS,
    strip_include_prefix = "//cuttlefish",
    deps = [
        "//cuttlefish/common/libs/fs",
        "//cuttlefish/common/libs/utils:contains",
        "//cuttlefish/common/libs/utils:json",
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/common/libs/utils:subprocess",
        "//cuttlefish/host/libs/directories",
        "//cuttlefish/host/libs/web/http_client",
        "//cuttlefish/host/libs/web/http_client:http_json",
        "//cuttlefish/host/libs/web/http_client:url_escape",
        "//cuttlefish/host/libs/web:credential_source",
        "//libbase",
        "@zlib",
    ],
)

cc_library(
    name = "remote_zip",
    srcs = ["remote_zip.cc"],
    hdrs = ["remote_zip.h"],
    copts = COPTS,
    strip_include_prefix = "//cuttlefish",
    features = ["-layering_check"], # libzip
    linkopts = ["-llzma"], # libzip
    linkstatic = True,
    deps = [
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/host/libs/web/http_client",
        "@libzip",
    ],
)

clang_tidy_test(
    name = "remote_zip_clang_tidy",
    srcs = [":remote_zip"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_test(
    name = "remote_zip_test",
    srcs = ["remote_zip_test.cc"],
    copts = COPTS,
    features = ["-layering_check"], # libzip
    deps = [
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/common/libs/utils:result_matchers",
        "//cuttlefish/host/libs/web/http_client",
        "//cuttlefish/host/libs/web/http_client:fake_http_client",
        "//cuttlefish/host/libs/web:remote_zip",
        "@abseil-cpp//absl/strings",
        "@googletest//:gtest",
        "@googletest//:gtest_main",
        "@libzip",
    ],
)

clang_tidy_test(
    name = "remote_zip_test_clang_tidy",
    srcs = [":remote_zip_test"],
    tags = ["clang_tidy", "clang-tidy"],
)
